import tkinter
from tkinter import ttk

class MainWindow():
    def __init__(self):
        self.root = tkinter.Tk()
        self.root.title('login')
        self.root.minsize(200, 200)
        self.root.geometry('250x300+300+200')
        self.add_layout()

    def add_layout(self):
        s = ttk.Style()
        s.configure('Danger.TFrame', background='red')
        frame = ttk.Frame(self.root, padding=5, style="Danger.TFrame")
        self.user_name = tkinter.StringVar()
        entry_name = ttk.Entry(frame, textvariable=self.user_name)
        entry_name.grid(column=0, row=0)
        self.user_pwd = tkinter.StringVar()
        entry_pwd = ttk.Entry(frame, textvariable=self.user_pwd)
        entry_pwd.grid(column=0, row=1)
        button_login = ttk.Button(frame, text='login', command=self.login)
        button_login.grid(column=0, row=2)
        frame.grid(column=0, row=0)




    def start(self):
        self.root.mainloop()

    def login(self):
        print(f'账号是{self.user_name.get()}密码是{self.user_pwd.get()}登陆了')

mw = MainWindow()
mw.start()